﻿/*common*/
var LG=(function(lg){
    lg.inputPrompt=function(selector,text){    
        $(selector).val(text)
        .data("color",$(selector).css("color"))
        .css("color","gray")
        .blur(function(){
            if($(this).val()==""){
                $(this).val(text).css("color","gray");
            }
        }).focus(function(){
            if($(this).val()==text){
                $(this).val("")
                .css("color",$(this).data("color"));
            }
        }); 
    };
    lg.showJSON = function(obj, div) {
        var result = "";
        var line = "\r\n";
        if (div) {
            line = "<br/>";
        }
        for (var p in obj) {
            result += p + ":" + obj[p] + "(" + typeof (obj[p]) + ")" + line;
        }
        if (div) {
            document.getElementById(div).innerHTML = result;
        }
        else {
            alert(result);
        }
    };
    lg.radioValue = function(name, value) {
        var rds = $("input[name='" + name + "']");
        for (var i = 0; i < rds.length; i++) {
            if (arguments.length == 1 && rds.eq(i).attr("checked")) {
                return rds.eq(i).val();
            }
            else if (arguments.length == 2 && rds.eq(i).val() == value) {
                rds.eq(i).attr("checked", true);
                return;
            }
        }
        return null;
    };
    return lg;
}(LG||{}));